# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=openpyxl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=3.1.2
pkgrel=2
pkgdesc="A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)"
url="https://openpyxl.readthedocs.io/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-jdcal"
         "${MINGW_PACKAGE_PREFIX}-python-et-xmlfile"
         "${MINGW_PACKAGE_PREFIX}-python-defusedxml"
         "${MINGW_PACKAGE_PREFIX}-python-pandas"
         "${MINGW_PACKAGE_PREFIX}-python-pillow")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-pytest")
source=("https://foss.heptapod.net/openpyxl/openpyxl/-/archive/${pkgver}/openpyxl-${pkgver}.tar.bz2")
sha256sums=('421e13e7004f6fee7cf84c1b9fa738615bf409ff2b57e2227be75452f7608c12')

prepare() {
  rm -rf python-build-${MSYSTEM}
  cp -r "openpyxl-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENCE.rst ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
